package com.larry.spark.rdd.transform

import org.apache.spark.rdd.RDD
import org.apache.spark.{SparkConf, SparkContext}

object RDD_Oper_Distinct {

  def main(args: Array[String]): Unit = {
    //TODO  使用spark distinct去重

    val conf = new SparkConf().setMaster("local[*]").setAppName("rdd")
    val sc = new SparkContext(conf)

    val rdd: RDD[Int] = sc.makeRDD(List(1,2,1,2,1,2))

    //map(x => (x, null)).reduceByKey((x, _) => x, numPartitions).map(_._1)
    val rdd1 = rdd.distinct()

    rdd1.collect().foreach(println)
    sc.stop()
  }
}
